**Code to generate the results in Table 3

*Census 1991
clear
cd "/Users/lucienetorresdemellopereira/Documents/EPGE_Mac/Doutorado/Censo/Censo91"
use Census_91.dta

*Generating location variables
gen rural = [sit_setor_C == 0]
gen slum= [subnormal==1 & sit_setor_C==1]
gen city= [subnormal==0 & sit_setor_C==1]

*Generating migration variables 
gen migrant_rural = 0
gen migrant_urban = 0
replace migrant_rural = 1 if sit_mun_ant == 0
replace migrant_urban = 1 if sit_mun_ant == 1

*Generating log of total income
gen ln_income_total = ln(rend_total)

*Generating labor experience variable
gen age_exp = idade-25
gen age_exp_sq = age_exp^2

*Renaming variables
rename idade age_years
rename sexo gender
rename anos_estudoB education

*Compute mincer regressions only for adult population in working age (25 to 65 years old)
keep if age_years >= 25 & age_years <=65

regress ln_income_total rural slum gender education migrant_rural migrant_urban age_exp age_exp_sq [iweight=peso_pess]

regress ln_income_total rural slum gender education age_exp age_exp_sq [iweight=peso_pess]


*Census 2000
clear
cd "/Users/lucienetorresdemellopereira/Documents/EPGE_Mac/Doutorado/Censo/Censo00"
use Census_00.dta

*Generating location variables
gen rural = [sit_setor_C == 0]
gen slum= [subnormal==1 & sit_setor_C==1]
gen city= [subnormal==0 & sit_setor_C==1]

*Generating log of total income
gen ln_income_total = ln(rend_total)

*Generating labor experience variable
gen age_exp = idade-25
gen age_exp_sq = age_exp^2

*Renaming variables
rename idade age_years
rename sexo gender
rename anos_estudoB education

*Compute mincer regressions only for adult population in working age (25 to 65 years old)
keep if age_years >= 25 & age_years <=65

regress ln_income_total rural slum gender education age_exp age_exp_sq [iweight=peso_pess]
